home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / NMK / Recorders / MenuCellCover.m < prev    next >
Text File  |  1995-06-12  |  1KB  |  68 lines

  1. /***** MenuCellCover.m -- MenuCellCover object implementation
  2.     NeXTstep Measurement Kit
  3.     by Alex Meyer <ameyer@phoenix.Princeton.EDU>
  4.     for computer science senior thesis
  5.     24 April 1992 -- created from ButtonCellCover.m
  6. *****/
  7.  
  8. #import <sys/time.h>
  9. #import <appkit/Application.h>
  10. #import "RMenuVars.h"
  11. #import "MenuCellCover.h"
  12.  
  13. #define VARSNAME ("MenuVars")
  14.  
  15. #define MICRO (1000000.0)
  16. #define DOUBLETIME(stv) ((double) (((unsigned long) (stv).tv_sec) \
  17.     + (((unsigned long) (stv).tv_usec) / MICRO)))
  18.  
  19. @implementation MenuCellCover
  20.  
  21. - makeVarsRect:(const NXRect *)rect
  22. {
  23.     id vars;
  24.  
  25.     vars = [RMenuVars alloc];
  26.     [vars initString:contents
  27.         tag:tag
  28.         rect:rect];
  29.     NXNameObject(VARSNAME,vars,self);
  30.     return (vars);
  31. }
  32.  
  33.  
  34.  
  35. - (BOOL)trackMouse:(NXEvent *)theEvent
  36.     inRect:(const NXRect *)cellFrame
  37.     ofView:controlView
  38. {
  39.     id vars;
  40.     BOOL res;
  41.     double time0,time1;
  42.     struct timeval start,finish;
  43.     struct timezone zone;
  44.  
  45.     gettimeofday(&start,&zone);
  46.     res = [super trackMouse:theEvent
  47.         inRect:cellFrame
  48.         ofView:controlView];
  49.     gettimeofday(&finish,&zone);
  50.     time0 = DOUBLETIME(start);
  51.     time1 = DOUBLETIME(finish);
  52.     vars = NXGetNamedObject(VARSNAME,self);
  53.     if (!(vars))
  54.         vars = [self makeVarsRect:cellFrame];
  55.     [vars incHits];
  56.     if (!(res))
  57.         [vars incCancel];
  58.     [vars timeFrom:time0
  59.         to:time1];
  60.     return (res);
  61. }
  62.  
  63. @end
  64.  
  65. #undef DOUBLETIME
  66. #undef MICRO
  67. #undef VARSNAME
  68.